package com.t8;

/**
 * Created by xuyiwei on 2018/7/19.
 */
class Act {
    public void say() {

    }
}

class HappyAct extends Act {
    public void say() {
        System.out.println("这是高兴的动作");
    }
}

class SadAct extends Act {
    public void say() {
        System.out.println("这是悲伤的动作");
    }
}

class CryAct extends Act {
    public void say() {
        System.out.println("这是哭的动作");
    }
}

class ActShow {
    private Act act = new HappyAct();

    public void change(int i) {
        switch (i) {
            case 1:
                act = new HappyAct();
                break;
            case 2:
                act = new SadAct();
                break;
            case 3:
                act = new CryAct();
                break;
            default:
                act = new HappyAct();
        }
    }

    public void say(){
        act.say();
    }
}

public class Transmogrify {
    public static void main(String[] args) {
        ActShow actShow = new ActShow();
        actShow.say();
        actShow.change(1);
        actShow.say();
        actShow.change(2);
        actShow.say();
        actShow.change(3);
        actShow.say();

    }
}
